<?php

class DatabaseSeeder extends Seeder {

	/**
	 * Run the database seeds.
	 *
	 * @return void
	 */
	public function run()
	{
		Eloquent::unguard();

		$this->call('UserTypeTableSeeder');
		$this->command->info('UserType table seeded!');

		$this->call('UserTableSeeder');
		$this->command->info('User table seeded!');

		$this->call('RequestTypeTableSeeder');
		$this->command->info('ItemRequestType table seeded!');

		$this->call('RequestStatusTableSeeder');
		$this->command->info('ItemRequestStatus table seeded!');

		$this->call('ItemLocationTableSeeder');
		$this->command->info('ItemLocation table seeded!');

		$this->call("RequestItemStatusTableSeeder");
		$this->command->info('ItemRequestItemStatusTable table seeded!');
	}

}

class UserTypeTableSeeder extends Seeder{
	public function run()
	{
		DB::table('user_types')->delete();
		UserType::create(array('description' => 'admin'));
		UserType::create(array('description' => 'user'));
	}
	
}

class UserTableSeeder extends Seeder{
	public function run()
	{
		DB::table('users')->delete();
		User::create(array('id'=>'1234', 'password' => Hash::make('aaa'), 'user_type_fk' => UserType::where('description', '=', 'admin')->firstOrFail()->pk, 'email'=>'lobotk50@gmail.com'));
		User::create(array('id'=>'5678', 'password' => Hash::make('aaa'), 'user_type_fk' => UserType::where('description', '=', 'user')->firstOrFail()->pk, 'email'=>'lobotk50@hotmail.com'));
	}
}

class RequestTypeTableSeeder extends Seeder{
	public function run()
	{
		DB::table('item_request_types')->delete();
		ItemRequestType::create(array('description' => 'existencias'));
		ItemRequestType::create(array('description' => 'pedido'));
	}
	
}

class RequestStatusTableSeeder extends Seeder{
	public function run()
	{
		DB::table('item_request_status')->delete();
		ItemRequestStatus::create(array('description' => 'enviada'));
		ItemRequestStatus::create(array('description' => 'resolviendo'));
		ItemRequestStatus::create(array('description' => 'resuelta'));
	}
	
}

class RequestItemStatusTableSeeder extends Seeder{
	public function run()
	{
		DB::table('item_request_item_status')->delete();
		ItemRequestItemStatus::create(array('description' => 'pendiente'));
		ItemRequestItemStatus::create(array('description' => 'aprobado'));
		ItemRequestItemStatus::create(array('description' => 'rechazado'));
		ItemRequestItemStatus::create(array('description' => 'despachado'));
	}
	
}

class ItemLocationTableSeeder extends Seeder{
	public function run()
	{
		DB::table('item_locations')->delete();
		ItemLocation::create(array('description' => 'cajón 1'));
	}
	
}